# CMake 最低版本号要求
cmake_minimum_required (VERSION 2.8)
# 工程名
# PROJECT(cmake-demo-src)
# 手动加入文件
SET(SRC_LIST main.c)
MESSAGE(STATUS "THIS IS BINARY " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "THIS IS SOURCE " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "THIS IS CMAKE CMAKE_CURRENT_SOURCE_DIR " ${CMAKE_CURRENT_SOURCE_DIR})

# 设置子目录
# set(SUB_DIR_LIST "${CMAKE_CURRENT_SOURCE_DIR}/dir1" "${CMAKE_CURRENT_SOURCE_DIR}/dir2")
set(SUB_DIR_LIST dir1 dir2)
foreach(sub_dir ${SUB_DIR_LIST})
    # 自动添加头文件路径
    INCLUDE_DIRECTORIES(${sub_dir})
    # 遍历源文件
    aux_source_directory(${sub_dir} SRC_LIST) # 将子目录下的所有源文件加入到SRC_LIST变量中
    MESSAGE(STATUS "SUB_DIR -> " ${sub_dir})
    MESSAGE(STATUS "SRC_LIST -> " ${SRC_LIST})
endforeach()


# 手动添加头文件路径
# INCLUDE_DIRECTORIES(dir1)
# INCLUDE_DIRECTORIES(dir2)

ADD_EXECUTABLE(cmake-demo ${SRC_LIST})

# 将执行文件安装到bin目录下
INSTALL(TARGETS cmake-demo DESTINATION bin)